
using System;
using System.Collections;
using System.Web.UI.WebControls;

namespace GiftNet.Model
{
	#region IntegralStat Model -(by fangyifeng at 2007-09-14 12:24:10)

	/// <summary>
	/// IntegralStat object'IntegralStat'.
	/// </summary>
	[Serializable]
	public class IntegralStat : System.IComparable
		{
		#region Member Variables
		
		protected Guid _id;
		protected int _statYear;
		protected int _statMonth;
		protected Guid _memberId;
		protected double _totalIntegral;
		protected double _useIntegral;
		protected double _leaveIntegral;
		protected DateTime _statDateTime;
		
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public IntegralStat() { }

		public IntegralStat( int statYear, int statMonth, Guid memberId, double totalIntegral, double useIntegral, double leaveIntegral, DateTime statDateTime )
		{
			this._statYear = statYear;
			this._statMonth = statMonth;
			this._memberId = memberId;
			this._totalIntegral = totalIntegral;
			this._useIntegral = useIntegral;
			this._leaveIntegral = leaveIntegral;
			this._statDateTime = statDateTime;
		}

		#endregion

		#region Public Properties

		public virtual Guid Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public virtual int StatYear
		{
			get { return _statYear; }
			set { _statYear = value; }
		}

		public virtual int StatMonth
		{
			get { return _statMonth; }
			set { _statMonth = value; }
		}

		public virtual Guid MemberId
		{
			get { return _memberId; }
			set { _memberId = value; }
		}

		public virtual double TotalIntegral
		{
			get { return _totalIntegral; }
			set { _totalIntegral = value; }
		}

		public virtual double UseIntegral
		{
			get { return _useIntegral; }
			set { _useIntegral = value; }
		}

		public virtual double LeaveIntegral
		{
			get { return _leaveIntegral; }
			set { _leaveIntegral = value; }
		}

		public virtual DateTime StatDateTime
		{
			get { return _statDateTime; }
			set { _statDateTime = value; }
		}

        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public virtual int CompareTo(object obj)
        {
			if (!(obj is IntegralStat))
				throw new InvalidCastException("This object is not of type IntegralStat");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
					relativeValue = this.Id.CompareTo(((IntegralStat)obj).Id);
					break;
				case "StatYear":
					relativeValue = this.StatYear.CompareTo(((IntegralStat)obj).StatYear);
					break;
				case "StatMonth":
					relativeValue = this.StatMonth.CompareTo(((IntegralStat)obj).StatMonth);
					break;
				case "MemberId":
					relativeValue = this.MemberId.CompareTo(((IntegralStat)obj).MemberId);
					break;
				case "TotalIntegral":
					relativeValue = this.TotalIntegral.CompareTo(((IntegralStat)obj).TotalIntegral);
					break;
				case "UseIntegral":
					relativeValue = this.UseIntegral.CompareTo(((IntegralStat)obj).UseIntegral);
					break;
				case "LeaveIntegral":
					relativeValue = this.LeaveIntegral.CompareTo(((IntegralStat)obj).LeaveIntegral);
					break;
				case "StatDateTime":
					relativeValue = this.StatDateTime.CompareTo(((IntegralStat)obj).StatDateTime);
					break;
                default:
                    goto case "Id";
			}
            if (IntegralStat.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
